\(\int \frac {\cot ^2(a+i \log (x))}{x^2} \, dx\) [199]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [A] (verification not implemented)
   Maxima [B] (verification not implemented)
   Giac [A] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 15, antiderivative size = 64 \[ \int \frac {\cot ^2(a+i \log (x))}{x^2} \, dx=\frac {e^{2 i a}}{x \left (e^{2 i a}-x^2\right )}-\frac {3 x}{e^{2 i a}-x^2}-2 e^{-i a} \text {arctanh}\left (e^{-i a} x\right ) \]

[Out]

exp(2*I*a)/x/(exp(2*I*a)-x^2)-3*x/(exp(2*I*a)-x^2)-2*arctanh(x/exp(I*a))/exp(I*a)

Rubi [A] (verified)

Time = 0.08 (sec) , antiderivative size = 64, normalized size of antiderivative = 1.00, number of steps used = 5, number of rules used = 5, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.333, Rules used = {4592, 456, 473, 393, 213} \[ \int \frac {\cot ^2(a+i \log (x))}{x^2} \, dx=-2 e^{-i a} \text {arctanh}\left (e^{-i a} x\right )-\frac {3 x}{-x^2+e^{2 i a}}+\frac {e^{2 i a}}{x \left (-x^2+e^{2 i a}\right )} \]

[In]

Int[Cot[a + I*Log[x]]^2/x^2,x]

[Out]

E^((2*I)*a)/(x*(E^((2*I)*a) - x^2)) - (3*x)/(E^((2*I)*a) - x^2) - (2*ArcTanh[x/E^(I*a)])/E^(I*a)

Rule 213

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(-(Rt[-a, 2]*Rt[b, 2])^(-1))*ArcTanh[Rt[b, 2]*(x/Rt[-a, 2])]
, x] /; FreeQ[{a, b}, x] && NegQ[a/b] && (LtQ[a, 0] || GtQ[b, 0])

Rule 393

Int[((a_) + (b_.)*(x_)^(n_))^(p_)*((c_) + (d_.)*(x_)^(n_)), x_Symbol] :> Simp[(-(b*c - a*d))*x*((a + b*x^n)^(p
 + 1)/(a*b*n*(p + 1))), x] - Dist[(a*d - b*c*(n*(p + 1) + 1))/(a*b*n*(p + 1)), Int[(a + b*x^n)^(p + 1), x], x]
 /; FreeQ[{a, b, c, d, n, p}, x] && NeQ[b*c - a*d, 0] && (LtQ[p, -1] || ILtQ[1/n + p, 0])

Rule 456

Int[(x_)^(m_.)*((a_) + (b_.)*(x_)^(n_))^(p_.)*((c_) + (d_.)*(x_)^(n_))^(q_.), x_Symbol] :> Int[x^(m + n*(p + q
))*(b + a/x^n)^p*(d + c/x^n)^q, x] /; FreeQ[{a, b, c, d, m, n}, x] && NeQ[b*c - a*d, 0] && IntegersQ[p, q] &&
NegQ[n]

Rule 473

Int[((e_.)*(x_))^(m_)*((a_) + (b_.)*(x_)^(n_))^(p_)*((c_) + (d_.)*(x_)^(n_))^2, x_Symbol] :> Simp[c^2*(e*x)^(m
 + 1)*((a + b*x^n)^(p + 1)/(a*e*(m + 1))), x] - Dist[1/(a*e^n*(m + 1)), Int[(e*x)^(m + n)*(a + b*x^n)^p*Simp[b
*c^2*n*(p + 1) + c*(b*c - 2*a*d)*(m + 1) - a*(m + 1)*d^2*x^n, x], x], x] /; FreeQ[{a, b, c, d, e, p}, x] && Ne
Q[b*c - a*d, 0] && IGtQ[n, 0] && LtQ[m, -1] && GtQ[n, 0]

Rule 4592

Int[Cot[((a_.) + Log[x_]*(b_.))*(d_.)]^(p_.)*((e_.)*(x_))^(m_.), x_Symbol] :> Int[(e*x)^m*((-I - I*E^(2*I*a*d)
*x^(2*I*b*d))/(1 - E^(2*I*a*d)*x^(2*I*b*d)))^p, x] /; FreeQ[{a, b, d, e, m, p}, x]

Rubi steps \begin{align*} \text {integral}& = \int \frac {\left (-i-\frac {i e^{2 i a}}{x^2}\right )^2}{\left (1-\frac {e^{2 i a}}{x^2}\right )^2 x^2} \, dx \\ & = \int \frac {\left (-i e^{2 i a}-i x^2\right )^2}{x^2 \left (-e^{2 i a}+x^2\right )^2} \, dx \\ & = \frac {e^{2 i a}}{x \left (e^{2 i a}-x^2\right )}-e^{-2 i a} \int \frac {5 e^{4 i a}+e^{2 i a} x^2}{\left (-e^{2 i a}+x^2\right )^2} \, dx \\ & = \frac {e^{2 i a}}{x \left (e^{2 i a}-x^2\right )}-\frac {3 x}{e^{2 i a}-x^2}+2 \int \frac {1}{-e^{2 i a}+x^2} \, dx \\ & = \frac {e^{2 i a}}{x \left (e^{2 i a}-x^2\right )}-\frac {3 x}{e^{2 i a}-x^2}-2 e^{-i a} \text {arctanh}\left (e^{-i a} x\right ) \\ \end{align*}

Mathematica [A] (verified)

Time = 0.09 (sec) , antiderivative size = 72, normalized size of antiderivative = 1.12 \[ \int \frac {\cot ^2(a+i \log (x))}{x^2} \, dx=\frac {1}{x}-2 \text {arctanh}(x (\cos (a)-i \sin (a))) \cos (a)+2 i \text {arctanh}(x (\cos (a)-i \sin (a))) \sin (a)+\frac {2 x (\cos (a)-i \sin (a))}{\left (-1+x^2\right ) \cos (a)-i \left (1+x^2\right ) \sin (a)} \]

[In]

Integrate[Cot[a + I*Log[x]]^2/x^2,x]

[Out]

x^(-1) - 2*ArcTanh[x*(Cos[a] - I*Sin[a])]*Cos[a] + (2*I)*ArcTanh[x*(Cos[a] - I*Sin[a])]*Sin[a] + (2*x*(Cos[a]
- I*Sin[a]))/((-1 + x^2)*Cos[a] - I*(1 + x^2)*Sin[a])

Maple [A] (verified)

Time = 2.10 (sec) , antiderivative size = 38, normalized size of antiderivative = 0.59

method result size
risch \(\frac {1}{x}-\frac {2}{x \left (\frac {{\mathrm e}^{2 i a}}{x^{2}}-1\right )}-2 \,\operatorname {arctanh}\left (x \,{\mathrm e}^{-i a}\right ) {\mathrm e}^{-i a}\) \(38\)

[In]

int(cot(a+I*ln(x))^2/x^2,x,method=_RETURNVERBOSE)

[Out]

1/x-2/x/(exp(2*I*a)/x^2-1)-2*arctanh(x*exp(-I*a))*exp(-I*a)

Fricas [A] (verification not implemented)

none

Time = 0.24 (sec) , antiderivative size = 74, normalized size of antiderivative = 1.16 \[ \int \frac {\cot ^2(a+i \log (x))}{x^2} \, dx=-\frac {{\left (x^{3} - x e^{\left (2 i \, a\right )}\right )} e^{\left (-i \, a\right )} \log \left (x + e^{\left (i \, a\right )}\right ) - {\left (x^{3} - x e^{\left (2 i \, a\right )}\right )} e^{\left (-i \, a\right )} \log \left (x - e^{\left (i \, a\right )}\right ) - 3 \, x^{2} + e^{\left (2 i \, a\right )}}{x^{3} - x e^{\left (2 i \, a\right )}} \]

[In]

integrate(cot(a+I*log(x))^2/x^2,x, algorithm="fricas")

[Out]

-((x^3 - x*e^(2*I*a))*e^(-I*a)*log(x + e^(I*a)) - (x^3 - x*e^(2*I*a))*e^(-I*a)*log(x - e^(I*a)) - 3*x^2 + e^(2
*I*a))/(x^3 - x*e^(2*I*a))

Sympy [A] (verification not implemented)

Time = 0.21 (sec) , antiderivative size = 46, normalized size of antiderivative = 0.72 \[ \int \frac {\cot ^2(a+i \log (x))}{x^2} \, dx=- \frac {- 3 x^{2} + e^{2 i a}}{x^{3} - x e^{2 i a}} - \left (- \log {\left (x - e^{i a} \right )} + \log {\left (x + e^{i a} \right )}\right ) e^{- i a} \]

[In]

integrate(cot(a+I*ln(x))**2/x**2,x)

[Out]

-(-3*x**2 + exp(2*I*a))/(x**3 - x*exp(2*I*a)) - (-log(x - exp(I*a)) + log(x + exp(I*a)))*exp(-I*a)

Maxima [B] (verification not implemented)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 276 vs. \(2 (50) = 100\).

Time = 0.22 (sec) , antiderivative size = 276, normalized size of antiderivative = 4.31 \[ \int \frac {\cot ^2(a+i \log (x))}{x^2} \, dx=-\frac {2 \, {\left ({\left (i \, \cos \left (a\right ) + \sin \left (a\right )\right )} \arctan \left (\sin \left (a\right ), x + \cos \left (a\right )\right ) + {\left (i \, \cos \left (a\right ) + \sin \left (a\right )\right )} \arctan \left (\sin \left (a\right ), x - \cos \left (a\right )\right )\right )} x^{3} + 2 \, {\left ({\left ({\left (-i \, \cos \left (a\right ) - \sin \left (a\right )\right )} \cos \left (2 \, a\right ) + {\left (\cos \left (a\right ) - i \, \sin \left (a\right )\right )} \sin \left (2 \, a\right )\right )} \arctan \left (\sin \left (a\right ), x + \cos \left (a\right )\right ) + {\left ({\left (-i \, \cos \left (a\right ) - \sin \left (a\right )\right )} \cos \left (2 \, a\right ) + {\left (\cos \left (a\right ) - i \, \sin \left (a\right )\right )} \sin \left (2 \, a\right )\right )} \arctan \left (\sin \left (a\right ), x - \cos \left (a\right )\right )\right )} x - 6 \, x^{2} + {\left (x^{3} {\left (\cos \left (a\right ) - i \, \sin \left (a\right )\right )} - {\left ({\left (\cos \left (a\right ) - i \, \sin \left (a\right )\right )} \cos \left (2 \, a\right ) + {\left (i \, \cos \left (a\right ) + \sin \left (a\right )\right )} \sin \left (2 \, a\right )\right )} x\right )} \log \left (x^{2} + 2 \, x \cos \left (a\right ) + \cos \left (a\right )^{2} + \sin \left (a\right )^{2}\right ) - {\left (x^{3} {\left (\cos \left (a\right ) - i \, \sin \left (a\right )\right )} - {\left ({\left (\cos \left (a\right ) - i \, \sin \left (a\right )\right )} \cos \left (2 \, a\right ) - {\left (-i \, \cos \left (a\right ) - \sin \left (a\right )\right )} \sin \left (2 \, a\right )\right )} x\right )} \log \left (x^{2} - 2 \, x \cos \left (a\right ) + \cos \left (a\right )^{2} + \sin \left (a\right )^{2}\right ) + 2 \, \cos \left (2 \, a\right ) + 2 i \, \sin \left (2 \, a\right )}{2 \, {\left (x^{3} - x {\left (\cos \left (2 \, a\right ) + i \, \sin \left (2 \, a\right )\right )}\right )}} \]

[In]

integrate(cot(a+I*log(x))^2/x^2,x, algorithm="maxima")

[Out]

-1/2*(2*((I*cos(a) + sin(a))*arctan2(sin(a), x + cos(a)) + (I*cos(a) + sin(a))*arctan2(sin(a), x - cos(a)))*x^
3 + 2*(((-I*cos(a) - sin(a))*cos(2*a) + (cos(a) - I*sin(a))*sin(2*a))*arctan2(sin(a), x + cos(a)) + ((-I*cos(a
) - sin(a))*cos(2*a) + (cos(a) - I*sin(a))*sin(2*a))*arctan2(sin(a), x - cos(a)))*x - 6*x^2 + (x^3*(cos(a) - I
*sin(a)) - ((cos(a) - I*sin(a))*cos(2*a) + (I*cos(a) + sin(a))*sin(2*a))*x)*log(x^2 + 2*x*cos(a) + cos(a)^2 +
sin(a)^2) - (x^3*(cos(a) - I*sin(a)) - ((cos(a) - I*sin(a))*cos(2*a) - (-I*cos(a) - sin(a))*sin(2*a))*x)*log(x
^2 - 2*x*cos(a) + cos(a)^2 + sin(a)^2) + 2*cos(2*a) + 2*I*sin(2*a))/(x^3 - x*(cos(2*a) + I*sin(2*a)))

Giac [A] (verification not implemented)

none

Time = 0.31 (sec) , antiderivative size = 87, normalized size of antiderivative = 1.36 \[ \int \frac {\cot ^2(a+i \log (x))}{x^2} \, dx=2 \, {\left (\frac {\arctan \left (\frac {x}{\sqrt {-e^{\left (2 i \, a\right )}}}\right ) e^{\left (-2 i \, a\right )}}{\sqrt {-e^{\left (2 i \, a\right )}}} + \frac {x e^{\left (-2 i \, a\right )}}{x^{2} - e^{\left (2 i \, a\right )}}\right )} e^{\left (2 i \, a\right )} + \frac {5 \, x^{2}}{x^{3} - x e^{\left (2 i \, a\right )}} - \frac {e^{\left (2 i \, a\right )}}{x^{3} - x e^{\left (2 i \, a\right )}} \]

[In]

integrate(cot(a+I*log(x))^2/x^2,x, algorithm="giac")

[Out]

2*(arctan(x/sqrt(-e^(2*I*a)))*e^(-2*I*a)/sqrt(-e^(2*I*a)) + x*e^(-2*I*a)/(x^2 - e^(2*I*a)))*e^(2*I*a) + 5*x^2/
(x^3 - x*e^(2*I*a)) - e^(2*I*a)/(x^3 - x*e^(2*I*a))

Mupad [B] (verification not implemented)

Time = 27.47 (sec) , antiderivative size = 47, normalized size of antiderivative = 0.73 \[ \int \frac {\cot ^2(a+i \log (x))}{x^2} \, dx=-\frac {2\,\mathrm {atanh}\left (\frac {x}{\sqrt {{\mathrm {e}}^{a\,2{}\mathrm {i}}}}\right )}{\sqrt {{\mathrm {e}}^{a\,2{}\mathrm {i}}}}-\frac {{\mathrm {e}}^{a\,2{}\mathrm {i}}-3\,x^2}{x^3-x\,{\mathrm {e}}^{a\,2{}\mathrm {i}}} \]

[In]

int(cot(a + log(x)*1i)^2/x^2,x)

[Out]

- (2*atanh(x/exp(a*2i)^(1/2)))/exp(a*2i)^(1/2) - (exp(a*2i) - 3*x^2)/(x^3 - x*exp(a*2i))